#ifndef TRANSFORMERCONTENTPORTREGIST_HPP_3
#define TRANSFORMERCONTENTPORTREGIST_HPP_3

#include "logger.hpp"
#include "transContentDispatcher.hpp"
#include "transContentDefine.h"
#include "transContentErrorCode.h"
#include "transContentRegistProtocol.hpp"
#include "transContentAssistent.hpp"
#include "transContentThreadPool.hpp"
#include "transContentIDispatcherResponse.hpp"

class TransContentPortRegist{
private:
	/// registing port
	int mRegistingPort;

	/// regist type: apply, get, test
	int mRegistingType;
	
	/// already exist port, default is -1
	int mAlreadyPort;

	/// regist wait timeout
	int mTimeout;

	/// use as a bool value, 0 is false, others is true
	int canBeRemoved;

	/// regist port result
	int mRegistResult;

	/// the regist result port
	int mRegistedPort;

	/// dump the reigst packet in or write or all
	int dumpFlag;

	/// the port record index
	vroute_t vid;

	/// dump regist file name
	char* dumpFilename;

	int returnType;
	
public:
	TransContentPortRegist():mRegistingPort(-1),mRegistingType(REGIST_PORT_TYPE_APPLY), mAlreadyPort(-1), mTimeout(INT_MAX), canBeRemoved(0), mRegistResult(0), mRegistedPort(-1), dumpFlag(0), vid(-1){
		log_info("reigst constructor");
		dumpFilename = NULL;
	}

	virtual ~TransContentPortRegist(){
		debug_enter();
		debug_leave();
	}

	void setRegistingPort(int port){
		this->mRegistingPort = port;
	}

	int getRegistingPort(){
		return mRegistingPort;
	}
	
	void setRegistingType(int type){
		this->mRegistingType = type;
	}

	int getRegsitingType(){
		return mRegistingType;
	}
	
	void setAlreadyRegistedPort(int port){
		this->mAlreadyPort = port;
	}
	int getAlreadyRegistedPort(){
		return mAlreadyPort;
	}
	
	
	void setVid(vroute_t vid){
		this->vid = vid;
	}
	vroute_t getVid(){
		return vid;
	}
	

	int getRegsitedPort(){
		return mRegistedPort;
	}
	
	int getRegistedResult(){
		return mRegistResult;
	}
	
	void SetdumpPacket(char* fileName, int towards){
		dumpFilename = fileName;
		dumpFlag = towards;
	}
	
	int response(char* buffer, int index);
	
	/////////////////////////////////////////////////////////////////
	/// the port manager call this method to show whether delete the port instance immediately
	///
	/// return:
	///		0: do not remove it
	///		1: despose the instance
	////////////////////////////////////////////////////////////////
	int canRemoved(){
		return canBeRemoved;
	}
	
	int regist();
};
#endif //TRANSFORMERCONTENTPORTREGIST_HPP_3
